import java.util.*;

public class Day5 {
    public static void main(String[] args) {
        int[] arr = {3,4,5,1,2};
        System.out.println(4>>1);
        //findMin(arr);


    }
    //30.串联所有字串（暴力解法，只通过一次）
    public List<Integer> findSubstring11(String s, String[] words) {
        Map<String,Integer> map2 = new HashMap<>();
        Set<String> set1 = new HashSet<>();//记录words数组
        Set<String> set2 = new HashSet<>();//记录一个答案是否重复
        Set<String> set3 = new HashSet<>();//记录最终答案，防止重复
        List<Integer> ret = new ArrayList<>();//记录返回值

        map2.clear();

        for(int i=0;i<words.length;i++) set1.add(words[i]);
        int n = words[0].length();
        int m = words.length;
        int len =  m*n;//答案串的长度
        int slow= 0;
        int fast= n-1;
        int start = -1;//记录起始位置
        while(fast+1 <= s.length()) {
            StringBuilder str = null;
            int i = slow;
            int j = fast;
            String tmp = s.substring(i,j+1);
            while(set1.contains(tmp) && set2.contains(tmp) == false) {
                if(start == -1) start = i;
                if(str == null) str = new StringBuilder(tmp);
                else str.append(tmp);set2.add(tmp);
                if(str.length() == len) break;
                i+=n;j+=n;
                if(j+1<=s.length()) tmp = s.substring(i,j+1);
                else break;
            }
            if(str != null && str.length() == len) {
                if(set3.contains(str.toString()) == false) {
                    ret.add(start);
                }
                start = -1;
                set3.add(str.toString());
            }
            set2.clear();
            slow++;
            fast++;
        }
        return ret;
    }
    public int findMin(int[] nums) {
        int left = 0,right = nums.length-1;
        if(nums[right] > nums[left]) return nums[left];
        while(left < right) {
            int mid = left + ((right-left)>>1);
            if(nums[mid] >= nums[left] && nums[mid] > nums[right]) {
                left = mid+1;
            }else if(nums[mid] > nums[left] && nums[mid] < nums[right]) {
                right = mid - 1;
            }else {
                right = mid;
            }
        }
        return nums[left];
    }
}
